package com.heeexy.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONObject;
import com.heeexy.example.dao.EmpsDao;
import com.heeexy.example.dao.GoodsDao;
import com.heeexy.example.dao.OrdersDao;
import com.heeexy.example.service.EmpsService;
import com.heeexy.example.service.OrdersService;
import com.heeexy.example.util.CommonUtil;

@Service
public class OrdersServiceImpl implements OrdersService{
	
	@Autowired
    private OrdersDao ordersDao;

	@Override
	public JSONObject listOrderO(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = ordersDao.countOrders(jsonObject);
        List<JSONObject> list =  ordersDao.orderO(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	@Override
	public JSONObject listOrderE(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = ordersDao.countOrders(jsonObject);
        List<JSONObject> list =  ordersDao.orderE(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}
	
	@Override
	public JSONObject listOrders(JSONObject jsonObject) {
		CommonUtil.fillPageParam(jsonObject);
        int count = ordersDao.countOrders(jsonObject);
        List<JSONObject> list =  ordersDao.listOrders(jsonObject);
        return CommonUtil.successPage(jsonObject, list, count);
	}

	 @Override
	 @Transactional(rollbackFor = Exception.class)
	public JSONObject updateOrders(JSONObject jsonObject) {
		 ordersDao.updateOrders(jsonObject);
	     return CommonUtil.successJson();
	}

	 @Override
	 @Transactional(rollbackFor = Exception.class)
	public JSONObject addOrders(JSONObject jsonObject) {
		 ordersDao.addOrders(jsonObject);
	     return CommonUtil.successJson();
	}

	 @Transactional(rollbackFor = Exception.class)
    @SuppressWarnings("unchecked")
    @Override
	public JSONObject deleteOrders(JSONObject jsonObject) {
		 ordersDao.deleteOrders(jsonObject);
	        return CommonUtil.successJson();
	}

}
